package Abstractions;

public abstract class HangmanAbstraction implements HangmanSpecification{
	
	/**
	 * The currentWord must only contain letters from the specified alphabet 
	 */
	public  String currentWord;
	
	/**
	 * This must be initialised to 0 and should be incremented every time an error is made;
	 * up to the maximum number of errors allowed
	 */
	public  int errorCount;
	
	/**
	 * lettersFound is an array for storing which of the letters of the current word have
	 * been found by the players correct guesses.<br>
	 * For example, if 't' has been guessed in the word "test" then the 
	 * lettersFound array will be [true, false, false, true]
	 */
	public boolean [] lettersFound;
	
	/**
	 * lettersTried is an array for storing which of the letters of the alphabet have
	 * been guessed by the player since the beginning of the game.<br>
	 * For example, if the player has tried letters 'a' 'c' and 'z' this array will have the
	 * value [true, false, true, false, ..., false, true]
	 */
	public boolean [] lettersTried = new boolean[ALPHABET_SIZE];
	
	
	public boolean won;
	
	public boolean lost;
	
	public abstract void tryLetter(char letter) throws IllegalStateException, IllegalArgumentException;
	
	public boolean invariant(){
		if (errorCount<0 || errorCount>ERROR_MAX) return false;
		if (currentWord.length() != lettersFound.length) return false;
		if (lettersTried.length != ALPHABET_SIZE) return false;
		if (won && lost) return false;
		return true;
	}
}
